package com.ling.pl.security.view.role.member;

import com.bstek.dorado.annotation.DataProvider;
import com.bstek.dorado.annotation.Expose;
import com.bstek.dorado.data.provider.Page;
import com.ling.core.common.utils.D7PageUtils;
import com.ling.pl.security.feign.DefaultRoleService;
import com.ling.pl.security.model.RoleMemberVO;
import com.ling.pl.security.view.role.RoleMaintain;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;
import java.util.Collection;
import java.util.Map;

@Component("ling2.roleMemberMaintain")
public class RoleMemberMaintain extends RoleMaintain {
    @Resource
    DefaultRoleService roleService;

    @DataProvider
    public void loadMembers(Page<RoleMemberVO> page, Map<String, Object> parameter) throws Exception {
        roleService.loadMembers(D7PageUtils.buildQueryParams(parameter, page));
    }

    @Expose
    public void changeGranted(Collection<Map<String, Object>> members) throws Exception {
        roleService.changeGranted(members);
    }

    @Expose
    public void deleteRoleMember(String memberId) throws Exception {
        roleService.deleteRoleMember(memberId);
    }

    @Expose
    public String insertRoleMember(Collection<String> ids, String type, String roleId) throws Exception {
        return roleService.insertRoleMember(ids, type, roleId);
    }
}
